package tcln.sors.service.core;

import java.util.List;

import tcln.sors.model.core.criteria.SearchCriteria;
import tcln.sors.model.core.criteria.SortInfo;

/**
 * Interface for a management service for an object type.
 * 
 * @param <T>
 *            Managed type.
 * @author Truong Chau Lien Ngoc (lienngoc@gmail.com)
 */
public interface ManagementService<T> {

    /**
     * Retrieves all objects.
     * 
     * @param sortInfo
     *            Sorting information or <code>null</code> to ignore sorting.
     * @return All objects sorted by given sort information.
     */
    List<T> listAll(SortInfo sortInfo);

    /**
     * Searches for objects matching given criteria.
     * 
     * @param criteria
     *            Search criteria, required.
     * @param sortInfo
     *            Sorting information or <code>null</code> to ignore sorting.
     * @return
     */
    List<T> search(SearchCriteria criteria, SortInfo sortInfo);

    /**
     * Saves (inserts/updates) an object.
     * 
     * @param object
     * @return Updated/inserted object, maybe a new object.
     */
    T save(T object);

    /**
     * Deletes an object.
     * 
     * @param object
     */
    void delete(T object);

    /**
     * Loads an object by its' ID.
     * 
     * @param objectId
     * @return
     */
    T get(Integer objectId);
}
